﻿using BCCommon;
using BCDto.Common.ErrorMessage;
using BCDto.TMS.SpecificServiceType;
using BCDto.TMS.TransferStation;
using BCEntity.TMS.SpecificServiceType;
using BCService.TMS.SpecificServiceType;
using BCService.TMS.SpecificServiceTypeOverWrite;
using BCService.TMS.TransferStation;
using BCTMSRESTful.Configs;
using BCTMSRESTful.Controllers.Management;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.Management.TMS.SpecificServiceTypeOverWrite
{
    /// <summary>
    /// 特殊服务类型接口
    /// </summary> 
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class SpecificServiceTypeOverWriteController : ManagementBaseController
    {
        #region var
        private ISpecificServiceTypeOverWriteService specificServiceTypeOverWriteService;

        #endregion

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 
        public SpecificServiceTypeOverWriteController(ISpecificServiceTypeOverWriteService specificServiceTypeOverWriteService)
        {
            this.specificServiceTypeOverWriteService = specificServiceTypeOverWriteService;
        }
        #endregion

        #region POST 添加  
        /// <summary>
        /// 添加新特殊服务类型纪录重写
        /// </summary>
        /// <param name="dto">重写特殊服务类型数据模型</param>
        /// <returns></returns>
        [Log("添加新特殊服务类型纪录重写")]
        [HttpPost]
        [ProducesResponseType(typeof(SpecificServiceTypeDto), 200)] 
        public IActionResult Post([FromBody] SpecificServiceTypeOverWriteRequestDto dto)
        {
            var a = specificServiceTypeOverWriteService.Add(dto, this.Admin);
            return Ok(a);
        }
        #endregion



        #region PUT 重写修改   
        /// <summary>
        /// 修改重写特殊服务类型纪录
        /// </summary>
        /// <param name="dto">重写特殊服务类型数据模型</param>
        /// <returns></returns>
        [Log("修改重写特殊服务类型纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(SpecificServiceTypeViewDto), 200)]
        public IActionResult Put([FromBody] SpecificServiceTypeOverWritePutDto dto)
        {
            var a = Ok(specificServiceTypeOverWriteService.Update(dto, this.Admin));
            return a;
        }
        #endregion

        #region 启用/禁用特殊服务类型纪录重写
        /// <summary>
        /// 启用/禁用特殊服务类型纪录重写
        /// </summary>
        /// <param name="specificServiceTypeOverwriteId">特殊服务类型纪录重写id</param>
        /// <param name="enabled">启用/禁用</param>
        /// <returns></returns>
        [Log("启用/禁用特殊服务类型纪录重写")] 
        [HttpPut("[action]/{specific_service_type_overwrite_id}/{enabled}")]
        [ProducesResponseType(typeof(SpecificServiceTypeViewDto), 200)]
        public IActionResult  Enable(
            [FromRoute(Name = "specific_service_type_overwrite_id")] int specificServiceTypeOverwriteId,
            [FromRoute(Name = "enable")] bool enabled)
        {
            return Ok(specificServiceTypeOverWriteService.UpdateEnable(this.Admin, specificServiceTypeOverwriteId, enabled));
        }
        #endregion


        #region Query 
        /// <summary>
        /// 查询特殊服务类型
        /// </summary>
        /// <param name="provinceCode">省代码</param>
        /// <param name="cityCode">市代码</param>
        /// <param name="countyCode">区县代码</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<SpecificServiceTypeDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "province_code")] string provinceCode,
            [FromQuery(Name = "city_code")] string cityCode,
            [FromQuery(Name = "county_code")] string countyCode,
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(specificServiceTypeOverWriteService.GetList(Admin, provinceCode, cityCode, countyCode, pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion

        #region Query 
        /// <summary>
        /// 查询特殊服务类型基础配置
        /// </summary> 
        /// <param name="enabled">启用</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<SpecificServiceTypeDto>), 200)]
        public IActionResult QueryBase(
            [FromQuery(Name = "enabled")] bool? enabled,
        [FromQuery(Name = "index")] int? pageIndex = 1,
        [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(specificServiceTypeOverWriteService.GetListBase(enabled,pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion

    }
}
